package com.kingyun.gpsinspection.purificationservice.facade.service.tdm;

import com.alibaba.fastjson.JSONArray;
import com.kingyun.gpsinspection.purificationservice.facade.model.jsm.EmployeeVo;
import com.kingyun.gpsinspection.purificationservice.facade.model.tdm.*;

import java.util.List;
import java.util.Map;

/**
 * Created by liyi on 2016/12/2.
 */
public interface WorkOrderService {
    /**
     * 构造工单列表展示所需数据结构
     *
     * @param workOrder
     * @return
     * @throws Exception
     */
    Map<String, Object> listMap(WorkOrder workOrder) throws Exception;

    /**
     * 展示确认工单table数据
     *
     * @param workOrderVo
     * @return
     */
    Map<String, Object> listConfirmMap(WorkOrderVo workOrderVo) throws Exception;

    /**
     * 保存工单
     *
     * @param workOrder
     */
    void saveWorkOrder(WorkOrder workOrder);

    /**
     * 保存工单：先保存taskLink，再保存workOrderList
     *
     * @param employeeVo
     * @param workOrderList
     * @param taskId        任务id
     * @param taskType      任务类型
     */
    int saveWorkOrderList(EmployeeVo employeeVo, String taskId, Short taskType, List<WorkOrderVo> workOrderList);

    /**
     * 根据主键更新
     *
     * @param employeeVo
     * @param workOrder
     * @return
     */
    int updateByPrimaryKey(EmployeeVo employeeVo, WorkOrder workOrder);

    /**
     * 根据主键ID更新状态
     *
     * @param employeeVo
     * @param workOrderId
     * @return
     */
    int updateStateByIds(EmployeeVo employeeVo, String workOrderId);

    /**
     * 根据工单主键ID查询
     *
     * @param workOrderId
     * @return
     * @throws Exception
     */
    WorkOrder findWorkOrderById(String workOrderId) throws Exception;

    /**
     * 根据任务ID查询
     *
     * @param taskId
     * @return
     * @throws Exception
     */
    List<WorkOrder> findByTaskId(String taskId) throws Exception;

    /**
     * 根据任务ID查询工单集合
     *
     * @param taskId
     * @return
     * @throws Exception
     */
    List<WorkOrderVo> findVoListByTaskId(String taskId) throws Exception;

    /**
     * 获取待办工单总数
     *
     * @param userId 当前登录人id
     */
    JSONArray queryMyTodoWorkOrderCount(String userId);

    int saveWorkOrderList(EmployeeVo employeeVo, TaskLink taskLink, List<WorkOrderVo> workOrderList);

    /**
     * 修改主任务工单
     *
     * @param id              主任务id
     * @param employeeVo      登陆人信息
     * @param workOrderVoList 工单列表
     */
    void updateWorkOrder(EmployeeVo employeeVo, String id, List<WorkOrderVo> workOrderVoList, PatrolInspection patrolInspection, Maintenance maintenance) throws Exception;
}
